<%@ page import="domain.Product" %><%--
  Created by IntelliJ IDEA.
  User: guo
  Date: 2017/10/23
  Time: 20:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h1 align="center">商品列表</h1>


  <table align="center" width="580px" border="1px"  cellpadding="0" id="product">
      <tr>
          <td width="10%">序号</td>
          <td width="40">商品名称</td>
          <td width="25%">价格</td>
          <td  width="25%">操作</td>
          <%--<%--%>
              <%--Product product= (Product) request.getAttribute("product");--%>
              <%--out.print(product);--%>
          <%--%>--%>
      </tr>
      <div  align="right">
          <a href="${pageContext.request.contextPath}/add.jsp">添加</a>
      </div>

<c:forEach var="p" items="${list}">
    <c:choose>
        <c:when test="${p.pid%2==0}">
            <tr  style="background-color: aqua">
                <td width="10%">${p.pid}</td>
                <td width="40">${p.pname}</td>
                <td width="25%">${p["market_price"]}</td>
                <td width="25%"><a href="${pageContext.request.contextPath}/updateServlet?pid=${p.pid}">修改</a>&nbsp&nbsp<a href="${pageContext.request.contextPath}/deleteServlet?pid=${p.pid}">删除</a></td>
            </tr>
        </c:when>
        <c:otherwise>
            <tr  style="background-color: red">
                <td width="10%">${p.pid}</td>
                <td width="40">${p.pname}</td>
                <td width="25%">${p["market_price"]}</td>
                <td width="25%"><a href="${pageContext.request.contextPath}/updateServlet?pid=${p.pid}">修改</a>&nbsp&nbsp<a href="${pageContext.request.contextPath}/deleteServlet?pid=${p.pid}">删除</a></td>
            </tr>
        </c:otherwise>
    </c:choose>
</c:forEach>
  </table>
</body>
</html>
